"""我自己定义的过滤器"""

from django import template
register = template.Library()

@register.filter("mobile")  #注册过滤器 来一个别名
def mobile_filter(content,flag = "****"):
    return content[:3] + flag + content[-3:]

@register.filter("sex")
def sex_filter(content):
    return "男" if content == 1 else "女"

@register.filter("price")
def price_filter(content):
    return "%.2f" % content